import requests
import os



class Dwon_data:

    def xiazai(self, url):

        print(1)

        r = requests.get(url)
        print(2)

        file_name = str(url).split("/")[-1]

        if os.path.exists(file_name):

            print("已经存在")

        else:
            with open(file_name, 'wb') as f:

                f.write(r.content)

        return file_name


if __name__ == "__main__":
    a = Dwon_data()
    a.xiazai(url='https://raw.githubusercontent.com/justmarkham/DAT8/master/data/chipotle.tsv')


